<script setup lang="ts">
import { useRouter } from 'vue-router'

const props = defineProps<{
  inheritor: any
}>()

const router = useRouter()

// 查看详情
const viewDetail = () => {
  router.push({
    path: '/front/inheritorDetail',
    query: { id: props.inheritor.id }
  })
}
</script>

<template>
  <div class="inheritor-card" @click="viewDetail">
    <div class="card-image">
      <el-image
          :src="inheritor.avatar"
          class="inheritor-avatar"
          fit="cover"
          loading="lazy"
          :alt="inheritor.name"
      >
        <template #error>
          <div class="image-error">
            <div class="error-icon">👤</div>
          </div>
        </template>
      </el-image>
    </div>

    <div class="card-content">
      <h3 class="inheritor-name">{{ inheritor.name }}</h3>
      <div class="inheritor-level">{{ inheritor.level }}</div>
      <div class="inheritor-title">{{ inheritor.title }}</div>
      <div class="inheritor-region">{{ inheritor.region }}</div>
      <div class="inheritor-intro">{{ inheritor.intro }}</div>
    </div>
  </div>
</template>

<style lang="scss" scoped>
.inheritor-card {
  cursor: pointer;
  background: white;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  border: 1px solid rgba(0, 0, 0, 0.06);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);

  &:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.15);
    border-color: #3498db;
  }

  .card-image {
    position: relative;
    width: 100%;
    height: 240px;

    .inheritor-avatar {
      width: 100%;
      height: 100%;
    }

    .image-error {
      display: flex;
      align-items: center;
      justify-content: center;
      width: 100%;
      height: 100%;
      background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);

      .error-icon {
        font-size: 48px;
        color: #95a5a6;
      }
    }
  }

  .card-content {
    padding: 20px;

    .inheritor-name {
      font-size: 18px;
      font-weight: bold;
      color: var(--text-primary);
      margin: 0 0 12px 0;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .inheritor-level {
      display: inline-block;
      padding: 4px 12px;
      background: var(--primary-color);
      color: white;
      font-size: 12px;
      border-radius: 20px;
      margin-bottom: 12px;
    }

    .inheritor-title {
      font-size: 14px;
      color: var(--text-secondary);
      margin-bottom: 8px;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .inheritor-region {
      font-size: 13px;
      color: var(--text-light);
      margin-bottom: 12px;
    }

    .inheritor-intro {
      font-size: 14px;
      color: var(--text-secondary);
      line-height: 1.5;
      display: -webkit-box;
      -webkit-line-clamp: 2;
      -webkit-box-orient: vertical;
      overflow: hidden;
      text-overflow: ellipsis;
    }
  }
}
</style>